package org.bridgen.runtime.model;

import org.bridgen.runtime.RecoveryHelper;
import org.bridgen.runtime.util.Interval;

/**
 * 
 * @author Emma Söderberg <emma add cs.lth.se>
 *
 */

public class EOF extends EndIsland {
	
	public EOF(LexicalNode previous, Interval interval) {
		super(previous, interval, "");
	}

	public boolean bridgeMatch(Island island, int tol) {
		return island instanceof SOF;
	}

	public boolean possibleConstructionSite(LexicalNode node) {
		return node.getPrevious() == null;
	}
	
	public void insertFakeIsland(Island island, LexicalNode node) {
		RecoveryHelper.insertBefore(island, node);
	}
	
	public LexicalNode clone(LexicalNode previous) {
		return new EOF(previous, getInterval().clone());
	}

	@Override
	protected StartIsland createStartIsland(Interval interval) {
		return new SOF(interval);
	}

	@Override
	protected boolean isStartIsland(LexicalNode node) {
		return node instanceof SOF;
	}
}
